package kr.ac.sch.cs.HelloBabyServer.UI;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.widget.TabHost;

public class ClassTabHost {
	/**
	 * @uml.property  name="mContext"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	Context mContext;
	/**
	 * @uml.property  name="mTabHost"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	TabHost mTabHost;
	
	public ClassTabHost(Context context, TabHost tabHost) {
		this.mContext = context;
		this.mTabHost = tabHost;
		
		this.mTabHost.setup();
	}
	
	public TabHost getObject() {
		return this.mTabHost;
	}
	
	public void AddLayout(int resource) {
		LayoutInflater.from(mContext).inflate(resource, mTabHost.getTabContentView(), true);
	}
	
	public void AddTab(String strId, String strTitle, int intTabIcon, int intContentViewId) {
		TabHost.TabSpec spec;
		
		spec = mTabHost.newTabSpec(strId);
		
		Drawable drawTabIcon;
		
		if(intTabIcon < 0) {
			drawTabIcon = null;
		}
		else {
			drawTabIcon = this.mContext.getResources().getDrawable(intTabIcon);
		}
		
		spec.setIndicator(strTitle, drawTabIcon);
		spec.setContent(intContentViewId);

		mTabHost.addTab(spec);
	}
}
